package net.sshiffon;

import java.awt.Color;


import groovy.beans.Bindable;
public class ConnectionSetting {
	@Bindable def user
	@Bindable def host
	@Bindable def port=22
	@Bindable def initialView='Shell'
	@Bindable boolean isKeepAlive=true
	@Bindable def keepAliveSeconds=60
	@Bindable def connectionTimeout=6000
	@Bindable def localPath="/"
	@Bindable def remotePath
	@Bindable def tunnels
	@Bindable def backgroundcolor= Color.WHITE.getRGB()
	@Bindable def foregroundcolor= Color.BLACK.getRGB()
	//def logger= org.apache.log4j.Logger.getLogger(ConnectionSetting.class)
	
	public fromMap(Map<String,?> map)
	{
		map.each { k,v  ->
			//prevent nulls in bound lists..
			if('initialView'.equals(k) && v==null) v='Shell'
			
			setProperty(k,v)
		//def setter= 'set' + k[0].toUpperCase() + k.substring(1)
		//this."$setter"(v) 
		}
	}
	 public Map<String,?> toMap()
	 {
		 Map<String,?> map2= [:]
		 this.metaClass.properties*.name
	        	.findAll{ it != 'property' && it != 'metaClass' && it != 'class' && it != 'propertyChangeListeners' }
				.each { map2."$it" = this."$it" }
		return map2
	 }
}
